package com.lhc.springboot_mybatispuls;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
 * @ClassName Swagger2
 * @Description:
 * @Author: Lhc
 * @CreateDate: 2020-11-26 15:14
 * @UpdateUser: asus
 * @UpdateDate: 2020-11-26 15:14
 * @UpdateRemark:
 * @Version: 1.0
 */
@Configuration
@EnableSwagger2
public class Swagger2 {

    @Bean
    public Docket createRestApi() {
        //http://localhost:8080/doc.html bootstarp路径
        //配置swagger2核心配置 docket，主要是添加要扫描controller的路径
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.lhc.springboot_mybatispuls.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("API查询")
                .description("更多Spring Boot相关文章尽在CSND和百度文档")
                //.termsOfServiceUrl("www.baidu.com")
                .license("Copyright 2017-2018 分享牛")
                .version("1.0")
                .build();
    }
}
